package com.sc.study.ar.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.sc.common.annotation.Log;
import com.sc.common.core.controller.BaseController;
import com.sc.common.core.domain.AjaxResult;
import com.sc.common.enums.BusinessType;
import com.sc.study.ar.domain.ScListenSubjectRegister;
import com.sc.study.ar.service.IScListenSubjectRegisterService;
import com.sc.common.utils.poi.ExcelUtil;
import com.sc.common.core.page.TableDataInfo;

/**
 * 听课登记Controller
 * 
 * @author sc
 * @date 2022-03-14
 */
@RestController
@RequestMapping("/study/sistensubjectregister")
public class ScListenSubjectRegisterController extends BaseController
{
    @Autowired
    private IScListenSubjectRegisterService scListenSubjectRegisterService;

    /**
     * 查询听课登记列表
     */
    @PreAuthorize("@ss.hasPermi('study:sistensubjectregister:list')")
    @GetMapping("/list")
    public TableDataInfo list(ScListenSubjectRegister scListenSubjectRegister)
    {
        startPage();
        List<ScListenSubjectRegister> list = scListenSubjectRegisterService.selectScListenSubjectRegisterList(scListenSubjectRegister);
        return getDataTable(list);
    }

    /**
     * 导出听课登记列表
     */
    @PreAuthorize("@ss.hasPermi('study:sistensubjectregister:export')")
    @Log(title = "听课登记", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ScListenSubjectRegister scListenSubjectRegister)
    {
        List<ScListenSubjectRegister> list = scListenSubjectRegisterService.selectScListenSubjectRegisterList(scListenSubjectRegister);
        ExcelUtil<ScListenSubjectRegister> util = new ExcelUtil<ScListenSubjectRegister>(ScListenSubjectRegister.class);
        util.exportExcel(response, list, "听课登记数据");
    }

    /**
     * 获取听课登记详细信息
     */
    @PreAuthorize("@ss.hasPermi('study:sistensubjectregister:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(scListenSubjectRegisterService.selectScListenSubjectRegisterById(id));
    }

    /**
     * 新增听课登记
     */
    @PreAuthorize("@ss.hasPermi('study:sistensubjectregister:add')")
    @Log(title = "听课登记", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ScListenSubjectRegister scListenSubjectRegister)
    {
        return toAjax(scListenSubjectRegisterService.insertScListenSubjectRegister(scListenSubjectRegister));
    }

    /**
     * 修改听课登记
     */
    @PreAuthorize("@ss.hasPermi('study:sistensubjectregister:edit')")
    @Log(title = "听课登记", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ScListenSubjectRegister scListenSubjectRegister)
    {
        return toAjax(scListenSubjectRegisterService.updateScListenSubjectRegister(scListenSubjectRegister));
    }

    /**
     * 删除听课登记
     */
    @PreAuthorize("@ss.hasPermi('study:sistensubjectregister:remove')")
    @Log(title = "听课登记", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(scListenSubjectRegisterService.deleteScListenSubjectRegisterByIds(ids));
    }
}
